//导入验证规则的包
const joi = require('joi')

//定义用户名和密码 id nickname emailc 头像的验证规则
const username = joi.string().alphanum().min(1).max(10).required()
const password = joi
  .string()
  .pattern(/^[\S]{6,12}$/)
  .required()
const id = joi.number().integer().min(1).required()
const nickname = joi.string().required()
const email = joi.string().email().required()
const avatar = joi.string().dataUri().required()

//定义验证规则和登录表单数据的规则对象
exports.reg_Login_Schema = {
  body: {
    username,
    password
  }
}
//定义 id nickname email
exports.update_Userinfo_Schema = {
  body: {
    id,
    nickname,
    email
  }
}
//更新密码
exports.update_Password_Schema = {
  body: {
    oldPwd: password,
    newPwd: joi.not(joi.ref('oldPwd')).concat(password)
  }
}
//更新头像
exports.update_Avater_Schema = {
  body: {
    avatar
  }
}
